package javabase.thinkinjava.nio;

import java.nio.charset.Charset;
import java.util.Iterator;
import java.util.SortedMap;

/**
 * @author fance
 * @date 18-4-30 上午8:37
 */
public class AvailableCharSets {
    public static void main(String[] args) {
        SortedMap<String, Charset> charsetSortedMap = Charset.availableCharsets();

        Iterator<String> iterator = charsetSortedMap.keySet().iterator();
        while (iterator.hasNext()) {
            String charsetName = iterator.next();
            System.out.print(charsetName);
            Iterator aliases = charsetSortedMap.get(charsetName).aliases().iterator();
            if (aliases.hasNext()) {
                System.out.print(" : ");
            }
            while (aliases.hasNext()) {
                System.out.print(aliases.next() + " ");
                if (aliases.hasNext()) {
                    System.out.print(",");
                }
            }
            System.out.println();
        }

    }
}
